const app = getApp();
import { shareData, setShare } from "../../utils/util";

Page({
  data: {
    qr: "",
    url: "https://zhineng.qusaoma.cn/qr.html?qr=",
  },
  onLoad(option) {
    const qr = option.qr || decodeURIComponent(option.scene);

    this.setData({
      url: "https://zhineng.qusaoma.cn/qr.html?qr=" + qr,
      qr
    });

    this.setShare();
  },

  // 分享
  setShare() {
    setShare();
  },

  // 监听分享事件
  onShareAppMessage() {
    const qr = this.data.qr;
    return shareData({
      title: "明片",
      path: `/pages/card/index?qr=${qr}`,
      imageUrl: qr,
    });
  },
});
